package com.lqg.bookLibrary.controller;

import com.lqg.bookLibrary.common.core.domain.JsonResult;
import com.lqg.bookLibrary.pojo.Type;
import com.lqg.bookLibrary.service.ITypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/type")
@CrossOrigin
public class TypeController {

    @Autowired
    private ITypeService typeService;


    @GetMapping("/first")
    public JsonResult getTypeFirst(){
        List<Type> list = typeService.lambdaQuery().isNull(Type::getFatherId).list();
        return JsonResult.success(list);
    }

    @GetMapping("/second")
    public JsonResult getTypeSecond(){
        List<Type> list = typeService.lambdaQuery().isNotNull(Type::getFatherId).list();
        return JsonResult.success(list);
    }

}
